#ifndef K_UTILITY_H
#define K_UTILITY_H
#pragma once

#include "K_Windows.h"
#include "KGlobal.h"
#include "KNamespace.h"
#include <cstdint>

K_NAMESPACE_BEG(KUtility)

struct cpu_rate_cache_t {
    cpu_rate_cache_t() : n(0) {}
    void update(HANDLE hProcess = NULL);
    FILETIME c, e, k, u, s;
    LONGLONG cpuLast, sysLast;
    size_t n;
};

bool getProcessCpuRate(cpu_rate_cache_t &cache, int *rate, HANDLE hProcess = NULL, int max = 100);
bool getProcessMemUsage(uint64_t *usage, HANDLE hProcess = NULL);
bool getThreadCpuRate(cpu_rate_cache_t &cache, int *rate, HANDLE hThread = NULL, int max = 100);
size_t numOfAvailableProcessors(HANDLE hProcess = NULL);
size_t numOfProcessors();
size_t pageSize();

K_NAMESPACE_END(KUtility)

#endif // K_UTILITY_H